<?php
namespace app\admin\model;

use think\Model;

class AccountModel extends Model{
	protected $table = 'tplay_user_account';
	#'类型  1:动态账户   2:矿池账户   3:静态分红  4:代数静态分红百分比  5充值到矿池，6提现',
	const TYPE = [1=>'动态账户',2=>'矿池账户',3=>'静态分红',4=>'代数静态分红百分比',5=>'充值到矿池',6=>'提现'];
	public function users()
	{
		return $this->belongsTo('UserModel','uid','id')->field('id,nickname,phone');
	}

	public function userinfo()
	{
		return $this->belongsTo('UserModel','uid','id');
	}

    public function puser()
    {
        return $this->belongsTo('UserModel','source_id','id');
    }

    /**
     * 根据搜索条件获取用户列表信息
     * @param $where
     * @param $offset
     * @param $limit
     */
    public function getUsersByWhere($offset, $limit,$where,$field)
    {
        return $this->where($where)->limit(($offset-1)*$limit, $limit)->field($field)->select();
    }

    /**
     * 根据搜索条件获取所有的用户数量
     * @param $where
     */
    public function getAllUsers($where)
    {
        return $this->where($where)->count();
    }
}